
import java.sql.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;


public class AdminTaFramVara extends HttpServlet{
    PrintWriter out;
    HttpSession ses;
    String titel;
    
    
    
//-----------doPost
    public void doPost(HttpServletRequest req, HttpServletResponse res){
        
        try{
            out=res.getWriter();
            ses = req.getSession();
        }catch(Exception e){}
        listaVaror();
        
    }//end doPost
    
//-----------doGet
    public void doGet(HttpServletRequest req, HttpServletResponse res){
        
        try{
            ses = req.getSession();
            out=res.getWriter();
        }catch(Exception e){}
        listaVaror();
    }//end doGet
    
//-------------listar upp alla varor, form action=VisaVaruInfo---------**
    public void listaVaror(){
        
        DBkoppling.setKoppling();
        ResultSet rs = null;
        
        try{
            rs=DBkoppling.getAktuellaVaror();
        }catch(SQLException e){
            
            out.println("Could not find table. SQL errors follows: <BR>");
            out.println("SQLException: " + e.getMessage() + "<BR>");
            out.println("SQLState:     " + e.getSQLState() + "<BR>");
            out.println("VendorError:  " + e.getErrorCode());
            out.println("</BODY></HTML>");
        }//try-catch
        
        try{
            
            while(rs.next()){
                String t = rs.getString("titel");
                out.print("<TR>");
                out.print("	<TD>");
                out.print("<P><A HREF=./AdminVara?titel="+t+">"+t+"</A></P>");
                out.print("	</TD>");
                out.print("</TR>");
                out.print("</TABLE>");
            }//while
            
            rs=null;
            
            
        }catch(SQLException e){
            
            out.println("Could not find table. SQL errors follows: <BR>");
            out.println("SQLException: " + e.getMessage() + "<BR>");
            out.println("SQLState:     " + e.getSQLState() + "<BR>");
            out.println("VendorError:  " + e.getErrorCode());
            out.println("</BODY></HTML>");
            
        }//try-catch
        finally{
            DBkoppling.kopplaNer();
        }
    }//end listaVaror
}//end class